//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.ruoyi.web.controller.task;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.live.base.domain.LiveExamTaskBarrage;
import com.ruoyi.live.task.service.LiveExamTaskBarrageService;
import com.ruoyi.live.tool.utils.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping({"/task"})
public class LiveExamTaskBarrageController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(LiveExamTaskBarrageController.class);
    @Autowired
    LiveExamTaskBarrageService service;

    public LiveExamTaskBarrageController() {
    }

    @RequestMapping({"/LiveExamTaskBarrageController/index"})
    public String index() {
        return "task/live_exam_task_barrage_list";
    }

    @ResponseBody
    @RequestMapping({"/LiveExamTaskBarrageController/query"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public TableDataInfo query(LiveExamTaskBarrage entity) {
        this.startPage();
        List<LiveExamTaskBarrage> list = this.service.query(entity);
        return this.getDataTable(list);
    }

    @ResponseBody
    @RequestMapping({"/LiveExamTaskBarrageController/add"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public Message add(LiveExamTaskBarrage entity) {
        try {
            this.service.addLiveExamTaskBarrage(entity);
            return new Message(true, "新增成功");
        } catch (Exception var3) {
            var3.printStackTrace();
            log.error("", var3);
            return new Message(false, "新增失败");
        }
    }

    @ResponseBody
    @RequestMapping({"/LiveExamTaskBarrageController/update"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public Message update(LiveExamTaskBarrage entity) {
        try {
            this.service.updateLiveExamTaskBarrage(entity);
            return new Message(true, "修改成功");
        } catch (Exception var3) {
            var3.printStackTrace();
            log.error("", var3);
            return new Message(false, "修改失败");
        }
    }

    @ResponseBody
    @RequestMapping({"/LiveExamTaskBarrageController/delete"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public Message delete(String id) {
        try {
            this.service.deleteLiveExamTaskBarrage(id.split(","));
            return new Message(true, "删除成功");
        } catch (Exception var3) {
            var3.printStackTrace();
            log.error("", var3);
            return new Message(false, "删除失败");
        }
    }

    @RequestMapping({"/LiveExamTaskBarrageController/view"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public ModelAndView view(Long id, String page) {
        ModelAndView mv = new ModelAndView("task/" + page);
        if (id != null) {
            try {
                mv.addObject("entity", this.service.getLiveExamTaskBarrage(id));
            } catch (Exception var5) {
                return (new ModelAndView("error")).addObject("tip", var5.getMessage());
            }
        }

        return mv;
    }
}
